package top.aigoo.project01.enums;

/**
 * 枚使用枚举表述常量数据字典
 * Created by  Mr.OYSHUO.欧阳大叔(1642302522@qq.com) on 2021/8/9
 */
public enum PersonInfoStateEnum {
    SUCCESS(0, "创建成功"),
    INNER_ERROR(-1001, "操作失败"),
    EMPTY(-1002, "用户信息为空");

    private int state;

    private String stateInfo;


    private PersonInfoStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    /**
     * 依据传入的state编码返回相应的enum值
     */
    public static PersonInfoStateEnum stateOf(int state) {
        for (PersonInfoStateEnum stateEnum : values()) {
            if (stateEnum.getState() == state) {
                return stateEnum;
            }
        }
        return null;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }
}
